<?php

namespace App\Http\Controllers\Api;

use App\Services\LinkageService;
use App\Traits\Api\SuccessOrFailure;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class LinkageController extends Controller
{
    use SuccessOrFailure;

    public function __construct(LinkageService $service)
    {
        $this->service = $service;
    }

    public function get_option(Request $request, LinkageService $linkageService)
    {
        $category = $request->get('category');

        if (!isset($category)) {
            $data = $this->failure('参数错误');
            return response()->jsonp($request->get('callback'), $data);
        }
        $result = $this->success('成功', '', $linkageService->getLinkagesOption($category, $request->get('pid')));
        return response()->jsonp($request->get('callback'), $result);
    }
}
